package com.example.demo.control;

import com.alibaba.fastjson.JSON;
import com.example.demo.pojo.BackRole;
import com.example.demo.service.RoleService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@ResponseBody
@Controller
public class RoleControl {
    @Resource
    RoleService roleService;
    @PostMapping("/j/RoleControl/show")
    public String RoleControl(String thispage){
        PageInfo<BackRole> backRolePageInfo=roleService.backroleinfo(Integer.parseInt(thispage),5,"","");
        return JSON.toJSONString(backRolePageInfo);
    }
//修改
    @PostMapping("/j/RoleControl/update")
    public String updateRoleControl(String name,int seq){

        String message=roleService.updateRole(name,seq);
        return message;
    }
    //插入
    @PostMapping("/j/RoleControl/insert")
    public String insertRoleControl(String name){

        String message=roleService.roleInsert(name);
        return message;
    }

    //删除
    @PostMapping("/j/RoleControl/delete")
    public String deleteRoleControl(int seq){
        String message=roleService.roleDelete(seq);
        return message;
    }

}
